package com.neu.mapper;


import com.neu.pojo.Emp;
import com.neu.pojo.EmpQueryParam;
import com.neu.service.EmpService;
import com.neu.service.impl.EmpServiceImpl;
import org.apache.ibatis.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {


//    @Select("select e.*,d.name from emp e left join dept d on e.dept_id=d.id \n" +
//            "where e.name like concat('%',#{name},'%') and gender = #{gender} and e.entry_date BETWEEN #{begin} and #{end}\n" +
//            "order by e.update_time desc")
    //public List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);
  public List<Emp> list(EmpQueryParam empQueryParam);
  //新增员工基本信息 使用数据库生成的主键 mybatis提供的主键返回
  @Options(useGeneratedKeys = true,keyProperty = "id")
  @Insert("insert into emp(username,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) \n" +
          "   values(#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime});")
  void insert(Emp emp);
  //批量删除员工基本信息

  void deleteByIds(List<Integer> ids);
  //根据ID查询员工信息以及工作经历信息
  Emp getById(Integer id);
  //根据ID更新员工基本信息
  void updateById(Emp emp);
  //统计员工职位人数
  //@MapKey("pos")
  List<Map<String,Object>> countEmpJobData();
  //统计员工性别人数
  List<Map<String, Object>> countEmpGenderData();
  @Select("select id,username,name from emp where username = #{username} and password = #{password}")
  Emp selectByUsernameAndPassword(Emp emp);

  @Select("select * from emp")
  List<Emp> findAll();
}
